/*
 * @lc app=leetcode.cn id=48 lang=cpp
 *
 * [48] 旋转图像
 */

// @lc code=start
class Solution {
public:
    void rotate(vector<vector<int>>& matrix) {
        int n = matrix.size();
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                int tmp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = tmp;
            }
        }
        for (auto& row : matrix) {
            int i = 0;
            int j = n - 1;
            while (i < j) {
                int tmp = row[i];
                row[i] = row[j];
                row[j] = tmp;
                i++;
                j--;
            }

        }
    }
};
// @lc code=end

